<!-- 企业信息查询 -->
<template>
  <div class="project-inquiry">
    <Form ref="formData" :model="formData" :label-width="80">
      <Row :gutter="30">
        <Col span="6">
          <FormItem label="项目名称" prop="projectName">
            <Input v-model="formData.projectName" placeholder="请输入"></Input>
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="地区" prop="city">
            <CityCascader ref="cityCascader" @getProvince="getProvince" />
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="反馈阶段" prop="feedbackPhase">
            <Select v-model="formData.feedbackPhase" placeholder="全部" clearable>
              <Option :value="value" v-for="(label, value) in EnumFeedbackPhase" :key="value">{{ label }}</Option>
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="30">
        <Col span="6">
          <FormItem label="反馈时间" prop="times">
            <DatePicker
              v-model="formData.times"
              format="yyyy/MM/dd"
              type="daterange"
              placeholder="请选择时间"
              style="width:100%"
            ></DatePicker>
          </FormItem>
        </Col>

        <Col span="18" class="com-action-search-btn">
          <Button type="primary" icon="md-search" @click="handleSubmit('formData')">查询</Button>
          <BtnPlain type="primary" @click="handleReset('formData')">
            <Icon type="md-refresh" />
            <span>重置</span>
          </BtnPlain>
        </Col>
      </Row>
    </Form>
    <Table :columns="columns" :data="listData">
      <template slot-scope="{ row }" slot="repetitionRate">
        <BtnPlain type="primary">{{ row.repetitionRate + '%' }}</BtnPlain>
      </template>
      <template slot-scope="{ row }" slot="location">
        <BtnText type="primary" @BtnClick="onViewLocation(row)">查看定位</BtnText>
      </template>
      <template slot-scope="{ row }" slot="acceptStatus">
        <BtnPlain :type="info.acceptStatus | getAcceptStatus">{{ row.acceptStatusName }}</BtnPlain>
      </template>
      <template slot-scope="{ row }" slot="view">
        <BtnText v-if="row.rootInformationTag === 'Derivative'" type="primary" @BtnClick="onSourceInfo(row)">查看源信息</BtnText>
      </template>
      <template slot-scope="{ row }" slot="action">
        <BtnText type="primary" @BtnClick="onView(row,'view')">详情</BtnText>
        <BtnText type="warning" @BtnClick="onFeedback(row,'feedback')">反馈</BtnText>
      </template>
    </Table>
    <PageAtion
      v-if="formData.total"
      :total="formData.total"
      :size.sync="formData.size"
      :page.sync="formData.page"
      @pageSizeChange="pageSizeChange"
    />
    <SourceInfo v-model="modalValue" :parentId="tableParentId" />
    <ViewLocation v-model="modalValueLocation" :info="locationInfo" />
  </div>
</template>

<script>
import SourceInfo from '@/pages/businessInformationManage/common/sourceInfo.vue'
import ViewLocation from '@/pages/businessInformationManage/common/viewLocation.vue'
import { busInfoTrackPageList } from '@/api/businessInformationManage.js'
import CityCascader from '@/pages/components/cityCascader'

export default {
  name: 'projectInquiry',
  components: { SourceInfo, ViewLocation, CityCascader },
  data () {
    return {
      tableParentId: '',
      formData: {
        projectName: '',
        feedbackDateStart: '',
        feedbackDateEnd: '',
        times: [],
        parentOrgId: '',
        province: '',
        city: '',
        feedbackPhase: '',
        page: 1,
        size: 10,
        total: 10,
      },
      columns: [
        {
          title: '项目名称',
          key: 'projectName',
          minWidth: 160,
          tooltip: true
        },
        {
          title: '信息类型',
          key: 'infoTypeName',
          minWidth: 160,
          tooltip: true
        },
        {
          title: '省份',
          key: 'province',
          minWidth: 120,
        },
        {
          title: '城市',
          key: 'city',
          minWidth: 120,
        },
        {
          title: '产业标记',
          key: 'industryMarkName',
          minWidth: 120,
          tooltip: true
        },
        {
          title: '项目位置',
          slot: 'location',
          minWidth: 120,
        },
        {
          title: '业主方',
          key: 'ownerCompanyName',
          minWidth: 160,
          tooltip: true
        },
        {
          title: '施工方',
          key: 'constructionName',
          minWidth: 160,
          tooltip: true
        },
        {
          title: '预计产值规模(万元)',
          key: 'outputScale',
          minWidth: 160,
        },
        {
          title: '项目阶段',
          key: 'projectStageName',
          minWidth: 100,
        },
        {
          title: '项目备注',
          key: 'projectRemark',
          minWidth: 240,
          tooltip: true
        },
        {
          title: '推送目标企业',
          key: 'pushCompany',
          minWidth: 240,
          tooltip: true
        },
        {
          title: '发布人',
          key: 'publisher',
          minWidth: 120,
        },
        {
          title: '反馈时间',
          key: 'lastNewFeedbackDate',
          minWidth: 170,
        },
        {
          title: '经营人员',
          key: 'busiPersonName',
          minWidth: 120,
        },
        {
          title: '反馈阶段',
          key: 'lastNewFeedbackPhaseName',
          minWidth: 120,
        },
        {
          title: '派生信息标签',
          slot: 'view',
          minWidth: 160,
        },
        {
          title: '操作',
          slot: 'action',
          width: 130,
          align: 'center',
          fixed: 'right'
        },
      ],
      listData: [],
      modalValue: false,
      modalValueLocation: false,
      // 接收状态
      EnumFeedbackPhase: {
        // PairingNotAgree: '未接收',
        ProjectNotDiscussed: '未接洽',
        ProjectFollowUp: '跟进中',
        ProjectAlreadyDeliverTender: '已投标',
        ProjectUnDeliverTender: '未投标',
        ProjectWinTheBid: '已中标',
        ProjectSignAContract: '已签约',
        Other: '其他',
        End: '已结束',
      },
      locationInfo: {}
    };
  },
  created () {
    this.init()
  },
  methods: {
    async init (companyId = '') {
      const request = {
        ...this.formData,
        feedbackDateStart: this.formData.times[0],
        feedbackDateEnd: this.formData.times[1],
        companyId
      }
      const { data, page, size, total } = await busInfoTrackPageList(request)
      this.listData = data
      this.formData = { ...this.formData, ...{ page, size, total } }
    },
    getProvince(arr){
      this.formData.province = arr[0] || ''
      this.formData.city = arr[1] || ''
    },
    handleReset (name) {
      this.$refs['cityCascader'].reset();
      this.$refs[name].resetFields();
      this.init()
    },
    handleSubmit (name) {
      this.init()
    },
    pageSizeChange () {
      this.init()
    },
    // 查看来源信息
    onSourceInfo (row) {
      this.tableParentId = row.parentId
      this.modalValue = true
    },
    // 详情
    onView (row, type) {
      const { busInfoTrackId } = row
      this.$router.push({ path: '/businessInfoTrackDetails', query: { busInfoTrackId } })
    },
    onFeedback (row) {
      const { busInfoTrackId } = row
      this.$router.push({ path: '/businessInfoTrackFeedback', query: { busInfoTrackId } })
    },
    onViewLocation (row) {
      this.modalValueLocation = true
      this.locationInfo = row
    },
  },
};
</script>

<style lang="less">
.project-inquiry .badge-alone {
  border-radius: 3px;
  padding: 0;
  min-width: 15px;
  height: 15px;
  font-size: 11px;
  line-height: 13px;
}
</style>
